package com.bsoft.gol.hcs.specialist.controller;

import com.bsoft.gol.hcs.common.bean.request.DecryptDataReq;
import ctd.controller.exception.ControllerException;
import hcn.util.BaseResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.bsoft.gol.hcs.specialist.bean.vo.IndexListVo;
import com.bsoft.gol.hcs.specialist.service.TeamChronicGroupService;
import com.bsoft.gol.hcs.utils.BaseRespUtil;

import java.util.List;

/**
 * @author fzy91
 * @title: TeamChronicGroupController
 * @projectName hcn-specialist-ssdev4
 * @description: TODO
 * @date 2021/12/2117:03
 */
@Controller
@RequestMapping(value = "/api/auth/teamChronicGroup")
public class TeamChronicGroupController {
    private static final Logger log = LoggerFactory.getLogger(TeamChronicGroupController.class);
    @Autowired
    private TeamChronicGroupService teamChronicGroupService;

    @RequestMapping(value = "/decryptData", method = RequestMethod.POST)
    @ResponseBody
    public BaseResponse<List<IndexListVo>> decryptData(@RequestBody DecryptDataReq request) {
        BaseResponse baseResponse = new BaseResponse();
        try {
            baseResponse.setData(teamChronicGroupService.decryptData(request));
        } catch (ControllerException e) {
            e.printStackTrace();
            return BaseRespUtil.setResultError(e.getMessage());
        }
        return baseResponse;

    }

    @RequestMapping(value = "/encryptData", method = RequestMethod.POST)
    @ResponseBody
    public BaseResponse<List<IndexListVo>> encryptData(@RequestBody DecryptDataReq request) {
        BaseResponse baseResponse = new BaseResponse();
        try {
            baseResponse.setData(teamChronicGroupService.encryptData(request));
        } catch (ControllerException e) {
            e.printStackTrace();
            return BaseRespUtil.setResultError(e.getMessage());
        }
        return baseResponse;

    }
}
